#ifndef _CC_TCP_LISTENER_H_
#define _CC_TCP_LISTENER_H_
#include <string.h>
#include <functional>
#include "poller.h"
#include "socketNet.h"
#include "ICC_TCP_Handler.h"
#include "Packet.h"




class HttpListener : public CPollerObject
{
public:
	using NewConnCb = std::function<int(int,struct sockaddr_in*)>;

public:
	HttpListener(NewConnCb new_conn_cb, int backlog = 256);
	virtual ~HttpListener();
 
public:  
	int Listen(const char* ip, uint16_t port);

protected:
	virtual int InputNotify();
	int proc_accept(struct sockaddr_in* peer, socklen_t* peerSize);
	int proc_request(struct sockaddr_in* peer);

public:
	int	_accept_cnt;
	int	_newfd_cnt;
	int*	_fd_array;
	struct sockaddr_in*  _peer_array;

	char	_bindAddr[128];
	uint16_t	_bindPort;
	int	_backlog;
	unsigned int	_flag;

private:
	NewConnCb _new_conn_cb;
};



#endif

